package com.sailfish.springbootdemo.controller.db2;


import com.sailfish.springbootdemo.pojo.Result;
import com.sailfish.springbootdemo.pojo.db2.AxiConfig;
import com.sailfish.springbootdemo.pojo.db2.PcbParentFactoryInfo;
import com.sailfish.springbootdemo.pojo.db5.BoardResult;
import com.sailfish.springbootdemo.service.db5.BoardProportionService;
import com.sailfish.springbootdemo.service.db2.PcbParentFactoryInfoService;
import com.sailfish.springbootdemo.utils.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("/thirdApiH3c/v1")
public class ThirdApiH3cController {

    @Autowired
    private PcbParentFactoryInfoService pcbParentFactoryInfoService;

    @Autowired
    private BoardProportionService boardProportionService;


    @PostMapping("/getFactoryInfo")
    public Result getFactoryInfo() {
        List<PcbParentFactoryInfo> all = pcbParentFactoryInfoService.getAll(null, null, null, null, null, null, null, null, null, null, null, null, 1, null);
        return ResultUtil.success(all);
    }

    @PostMapping("/getBoarProportion")
    public Result getBoarProportion() {
        System.out.println("start getBoarProportion");
        Result result = boardProportionService.getBoarProportion();
        return result;
    }

    @PostMapping("/getBoardTableInfo")
    public Result getBoardTableInfo(Integer page, Integer pageSize) {
        System.out.println("start getBoardTableInfo");
        Result result = boardProportionService.getBoardTableInfo(page,pageSize);
        return result;
    }

    @PostMapping("/getAxiConfigList")
    public Result getAxiConfigList() {
        try {
            List<AxiConfig> axiConfigList = boardProportionService.getAxiConfigList();
            return ResultUtil.success(axiConfigList);
        } catch (Exception e) {
            return ResultUtil.error(500, e.getMessage(), e.getMessage(), null);
        }
    }

    @PostMapping("/updateAxiConfig")
    public Result updateAxiConfig(@RequestBody String data)
    {
        Result result = boardProportionService.updateAxiConfig(data);
        return result;
    }
}
